﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace AgvSystem.Web.Agv_Dispatch_Detail
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtDispatch_Detail_Id.Text))
			{
				strErr+="Dispatch_Detail_Id格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtFrom_Station_Num.Text))
			{
				strErr+="From_Station_Num格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtTo_Station_Num.Text))
			{
				strErr+="To_Station_Num格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtDispatch_State.Text))
			{
				strErr+="Dispatch_State格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtAgv_Num.Text))
			{
				strErr+="Agv_Num格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtDispatch_Id.Text))
			{
				strErr+="Dispatch_Id格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtCreate_Time.Text))
			{
				strErr+="Create_Time格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtUpdate_Time.Text))
			{
				strErr+="Update_Time格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int Dispatch_Detail_Id=int.Parse(this.txtDispatch_Detail_Id.Text);
			int From_Station_Num=int.Parse(this.txtFrom_Station_Num.Text);
			int To_Station_Num=int.Parse(this.txtTo_Station_Num.Text);
			int Dispatch_State=int.Parse(this.txtDispatch_State.Text);
			int Agv_Num=int.Parse(this.txtAgv_Num.Text);
			int Dispatch_Id=int.Parse(this.txtDispatch_Id.Text);
			DateTime Create_Time=DateTime.Parse(this.txtCreate_Time.Text);
			DateTime Update_Time=DateTime.Parse(this.txtUpdate_Time.Text);

			AgvSystem.Model.Agv_Dispatch_Detail model=new AgvSystem.Model.Agv_Dispatch_Detail();
			model.Dispatch_Detail_Id=Dispatch_Detail_Id;
			model.From_Station_Num=From_Station_Num;
			model.To_Station_Num=To_Station_Num;
			model.Dispatch_State=Dispatch_State;
			model.Agv_Num=Agv_Num;
			model.Dispatch_Id=Dispatch_Id;
			model.Create_Time=Create_Time;
			model.Update_Time=Update_Time;

			AgvSystem.BLL.Agv_Dispatch_Detail bll=new AgvSystem.BLL.Agv_Dispatch_Detail();
			bll.Add(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
